﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>回滚</title>
    <!--
    1, 回滚界面。
    2，需要 FK_Flow,WorkID
    3, 调用方法 Rollback.htm?FK_Flow=001&WorkID=232
    -->
    <meta http-equiv="Access-Control-Allow-Origin" content="*" />
    <link href="../Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" />
    <link href="../Scripts/bootstrap/css/components-rounded.css" rel="stylesheet" />
    <link href="../Scripts/bootstrap/css/font-awesome.css" rel="stylesheet" />
    <link href="../Scripts/bootstrap/css/themes/default/style.min.css" rel="stylesheet" />
    <link href="../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../Scripts/commonYangYH.js"></script>
    <script src="../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../Scripts/bootstrap/js/jquery.cokie.min.js"></script>
    <script type="text/javascript" src="../Scripts/bootstrap/js/jstree.js"></script>
    <script type="text/javascript" src="../Scripts/bootstrap/js/jsTree.ddl.js"></script>
    <!-- 导入配置文件. -->
    <script type="text/javascript" src="../Scripts/config.js"></script>
    <script type="text/javascript" src="../Comm/Gener.js"></script>
    <style type="text/css">
        #TB_Doc
        {
            height: 132px;
            width: 433px;
        }
    </style>
    <script type="text/javascript">

        $(function () {

            var workID = GetQueryString("WorkID");
            var gwf = new Entity("BP.WF.GenerWorkFlow", workID);
            if (gwf.WFState != 3) {
                alert('该流程尚未完成，您不能执行回滚操作。');
                return;
            }

            var html = "";
            html += "<table>";
            html += "<caption>流程[" + gwf.Title + "]回滚</caption>";
            html += "<tr>";
            html += "<th>#</th>";
            html += "<th>日期</th>";
            html += "<th>节点ID</th>";
            html += "<th>名称</th>";
            html += "<th>操作人</th>";
            html += "<th>操作人名称</th>";
            html += "<th>执行</th>";
            html += "</tr>";

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
            handler.AddUrlData();
            var ens = handler.DoMethodReturnJSON("Rollback_Init");

            for (var i = 0; i < ens.length; i++) {
                var en = ens[i];

                html += "<tr>";
                html += "<td>" + (i + 1) + "</td>";
                html += "<td>" + en.RDT + "</td>";
                html += "<td>" + en.NDFrom + "</td>";
                html += "<td>" + en.NDFromT + "</td>";
                html += "<td>" + en.EmpFrom + "</td>";
                html += "<td>" + en.EmpFromT + "</td>";
                html += "<td><a href=\"javascript:Done('" + en.NDFrom + "','" + en.EmpFrom + "');\">执行</a></td>";
                html += "</tr>";
            }

            html += "</table>";

            $("#docs").html(html);
        });

        //获取树选中的值
        function Done(nodeID, workid) {

            var flowNo = GetQueryString("FK_Flow");
            var workID = GetQueryString("WorkID");

            var msg = window.prompt('请输入回滚原因', '审核错误，需要回滚到该节点上重新审批。');
            if (msg == null || msg == undefined)
                return;

            var flow = new Entity("BP.WF.Template.FlowExt", flowNo);
            var data = flow.DoMethodReturnString("DoRebackFlowData", workID, nodeID, msg);

            alert(data);
            window.close();

        }
    </script>
</head>
<body>
    <div id="docs">
    </div>
</body>
</html>
